package LeetCode.leetcode1;

import java.util.HashMap;

public class Review1 {
    public int[] twoSum(int[] nums, int target) {
        HashMap<Integer,Integer> map = new HashMap<>(nums.length);
        int[] res = new int[2];
        for (int i = 0; i < nums.length; i++) {
            if (!map.containsKey(target-nums[i])){
                map.put(nums[i],i);
            }else {
                return new int[]{map.get(target-nums[i]),i};
            }
        }
        return res;
    }
}
